//
//  AppDelegate.swift
//  JTYP
//
//  Created by Groot on 2017/11/22.
//  Copyright © 2017年 inspur. All rights reserved.
//

import UIKit
import IQKeyboardManagerSwift

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        
        //Thread.sleep(forTimeInterval: 0.7)
        IQKeyboardManager.sharedManager().enable = true

        appearanceSetup()
        changeStoryboard()
        return true
    }
    
    func changeStoryboard() {
        if let _ = CUserManager.shareInstance.cUser {
            let sb = UIStoryboard.init(name: "Main", bundle: nil)
            self.window?.rootViewController = sb.instantiateInitialViewController()
        }else {
            let sb = UIStoryboard.init(name: "Login", bundle: nil)
            self.window?.rootViewController = sb.instantiateInitialViewController()
        }
    }
    
    func appearanceSetup() {
        let backImg = UIImage.init(named: "overall_fanhui")
        
        ToastManager.shared.position = .center
        
        UINavigationBar.appearance().backIndicatorImage = backImg
        UINavigationBar.appearance().backIndicatorTransitionMaskImage = backImg
        UINavigationBar.appearance().tintColor = UIColorFromRGB(rgbValue: 0x666666)
        UINavigationBar.appearance().isTranslucent = false
        UINavigationBar.appearance().barTintColor = UIColor.init(white: 0.975, alpha: 1.0)
        UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.font : UIFont.systemFont(ofSize: 19),NSAttributedStringKey.foregroundColor:UIColorFromRGB(rgbValue: 0x666666)]
        
        UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.font: UIFont.systemFont(ofSize: 12.5)], for: .normal)
    }
}

